package com.towexin.application.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.towexin.application.system.domain.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.Map;

@Mapper
public interface UserMapper extends BaseMapper<User> {
	// 获取用户信息带分页、模糊查询及角色id
	@Select("SELECT a.id,a.username,a.nickname,a.created_time,a.update_time,a.status,a.online,b.r_id,c.role_name FROM t_user a LEFT JOIN t_user_role b ON a.id=b.u_id LEFT JOIN t_role c ON c.id=b.r_id WHERE a.nickname LIKE #{nickname}")
	IPage<Map<String, Object>> selectUserAndRoleAndPage(IPage<Map<String, Object>> page, String nickname);

	@Select("SELECT nickname FROM t_user WHERE username = #{username}")
	String getNicknameByUsernameString(String username);
}
